package com.bolt.auth.security.admin.biz.sys.repository;


import com.bolt.auth.admin.api.sys.entity.RoleR2Privilege;
import com.bolt.support.spring.jpa.repository.BasicJpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface RoleR2PrivilegeRepository extends BasicJpaRepository<RoleR2Privilege, String> {

    @Query("select r2 from RoleR2Privilege r2  inner join r2.privilege as p  inner join r2.role r where p.enabled=true and r.code != :excludeRoleCode order by p.code desc")
    List <RoleR2Privilege> findEnabledExcludeRole(@Param("excludeRoleCode") String excludeRoleCode);

    List <RoleR2Privilege> findByPrivilege_Id(String privilegeId);
}
